package com.bwie.controller;

import com.bwie.pojo.TbProd;
import com.bwie.pojo.TbProdAtta;
import com.bwie.pojo.TbProdInfo;
import com.bwie.service.TbProdService;
import com.bwie.utils.R;
import com.bwie.vo.PageInfoVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author: badaotianqiong
 * @Date: 2025/7/22 17:15
 * @Description:
 **/
@RestController
@RequestMapping("/product/index")
public class ProdController {
    @Autowired
    private TbProdService tbProdService;


    @PostMapping("getProdList")
    public R getProdList(@RequestBody PageInfoVo pageInfoVo){
        return tbProdService.getProdList(pageInfoVo);
    }

    @PostMapping("addProd")
    public R addProd(@RequestBody @Validated TbProd tbProd){
        return tbProdService.addProd(tbProd);
    }

    @PostMapping("addProdAtta")
    public R addProdAtta(@RequestBody TbProdAtta tbProdAtta){
        return tbProdService.addProdAtta(tbProdAtta);
    }

    @PostMapping("deleteBatchProd")
    public R deleteBatchProd(@RequestBody List<Integer> ids){
        return tbProdService.deleteBatchProd(ids);
    }

    @PostMapping("deleteByProdId/{prodId}")
    public R deleteByProdId(@PathVariable("prodId") Integer prodId){
        return tbProdService.deleteByProdId(prodId);
    }


    @PostMapping("getProdByProdId/{prodId}")
    public R getProdByProdId(@PathVariable("prodId") Integer prodId){
        return tbProdService.getProdByProdId(prodId);
    }

    @PostMapping("getProdInfoList")
    public R getProdInfoList(@RequestBody PageInfoVo pageInfoVo){
        return tbProdService.getProdInfoList(pageInfoVo);
    }

    @PostMapping("addProdInfo")
    public R addProdInfo(@RequestBody TbProdInfo tbProdInfo){
        return tbProdService.addProdInfo(tbProdInfo);
    }

}
